﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace MilkCart.Convertors
{
    public sealed class DateTimeConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var val = value as DateTime?;
            if (val == null || targetType != typeof(string))
                return "none";

            // TODO : Make dates more friendly
            return val.Value.ToLocalTime().ToString("d", CultureInfo.CurrentUICulture);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
